Developer --> Technical Publications

 


Drawing Custom Previews

By default, Navigation Services draws a preview in the Open dialog box when a file selected in the browser list contains a valid 'pnot' component. To override how previews are drawn and handled, you can create a preview-drawing function, as described in . You register your preview-drawing function by passing a Universal Procedure Pointer (UPP) in the previewProc parameter of a Navigation Services function such as . You obtain this UPP by calling the macro NewNavPreviewProc and passing a pointer to your preview-drawing function. When the user selects a file, Navigation Services calls your preview-drawing function. Before you attempt to create a custom preview, your application should determine whether previews are enabled by specifying the kNavCtlIsPreviewShowing constant in the NavCustomControlMessages parameter of the function .

Your preview-drawing function obtains information from a structure of type specified in the callBackParms parameter of your event-handling function. The structure contains the following information:

  • The eventData field contains a structure of type describing the file to be previewed. This structure provides an Apple event descriptor list ( AEDescList ) that you must be able to coerce into a file specification ( FSSpec) . If you cannot coerce the AEDescList into a valid FSSpec , the object is not a file and you should not attempt to create a preview.
  • The previewRect field describes the preview area, which is the section of the dialog box reserved for preview drawing.
  • The window field identifies the window to draw in.
  • Once you have determined that previews are enabled, your preview-drawing function should draw the custom preview in the specified area and return a function result of true . If you don't want to draw a preview for a given file, be sure to return a function result of false .


    © 2000 Apple Computer, Inc. (Last Updated 18 April 00)